package com.arc.message;

import arc.ArcBase;
import arc.ArcBase.Type;
import arc.ArcClient;
import com.arc.state.MessageState;
import com.jme3.network.AbstractMessage;
import com.jme3.network.Client;
import com.jme3.network.Server;
import com.jme3.network.serializing.Serializable;

@Serializable
public class Authentication extends AbstractMessage {
    private int clientVersion;
    private String clientGameName;
    public boolean authenticated;
    /*public MessageState state = new MessageState()
    {
        @Override
        public void synLogic(ArcBase app, ArcBase.Type type, Object[] param) {
            if(type.equals(ArcBase.Type.Server))
            {
                if((Boolean)param[0])
                    nextState();
            }
        }
        @Override
        public void ackLogic(ArcBase app, Type type, Object[] param) {
            if(type.equals(ArcBase.Type.Client))
            {
                if(((ArcClient)app).isAuthenticated)
                    state.forceState(MessageState.STATE_KILL);
            }
        }

        @Override
        public void initializeLogic(ArcBase app, Type type, Object[] param) {
            nextState();
        }

        @Override
        public void killLogic(ArcBase app, Type type, Object[] param) {
            return;
        }

        @Override
        public void updateState(ArcBase app, ArcBase.Type type, Object[] params)
        {
            switch(getIndex())
            {
                case MessageState.STATE_INITIALIZE:
                    initializeLogic(app, type, params);
                    break;
                case MessageState.STATE_SYN:
                    synLogic(app, type, params);
                    break;
                case MessageState.STATE_ACK:
                    ackLogic(app, type, params);
                    break;
                case MessageState.STATE_KILL:
                    killLogic(app, type, params);
                    break;
            }
        }
        
    };*/
    
    public Authentication() { 
    }
    
    public Authentication(int version, String gameName)
    {
        this.clientVersion = version;
        this.clientGameName = gameName;
    }
    
    //public MessageState getState(){ return state; }
    public int getClientVersion(){ return clientVersion; }
    public String getClientName(){ return clientGameName; }
}
